import { _decorator, Component, find, Node, NodeEventType, UIOpacity } from 'cc';
import { MainLlogic } from '../scripts/MainLlogic';
const { ccclass, property } = _decorator;

@ccclass('Startbtn')
export class Startbtn extends Component {

    private mainLogic:Node = null
    opacity:UIOpacity

    opacityc:number = -1
    start() {
        this.mainLogic = find('Canvas/MainLogic')
        this.node.on(Node.EventType.TOUCH_START,this.touchStart,this)
        this.opacity = this.node.getComponent(UIOpacity)

    }
    touchStart(){
       this.mainLogic.getComponent(MainLlogic).curtainModeCame()
       this.node.destroy()
    }

    update(deltaTime: number) {
        if(this.opacity.opacity == 255)this.opacityc = -1
        if(this.opacity.opacity == 100)this.opacityc = 1
        this.opacity.opacity = this.opacity.opacity+ this.opacityc
    }
}


